/*
 * Copyright (C) 2008 aki@akjava.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.akjava.android.openglsamples.redbook;

import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.view.KeyEvent;

import com.akjava.lib.android.opengl.EventHandleRender;

public abstract class RedBookSimpleRenderer extends EventHandleRender{

 

    public RedBookSimpleRenderer(Context context) {
		super(context);
		
	}

	

   
    

    public void drawFrame(GL10 gl) {
        
        onDrawFrame(gl);
    }

   

    public Context getContext(){
    	return mContext;
    }
    protected Context mContext;
    protected FloatBuffer mFVertexBuffer;
    protected FloatBuffer mColorBuffer;
    protected FloatBuffer mTextureBuffer;
    protected ShortBuffer mIndexBuffer;
    
    public abstract void setUpBuffers();
    
    

    /*
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    	
    	if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
    		actionUp();
    	}else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
    	  actionDown();
    	}
    		if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
    			actionRight();
    		}else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
    			actionLeft();
    	}else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
    		actionCenter();
    	}
    	return true;
    }*/
    
   protected int xChange=10;
   protected int yChange=10;
   protected int rightLeftValue;
   protected int upDownValue;
    public void actionUp(){
    	upDownValue+=yChange;
		if(upDownValue>360){
			upDownValue-=360;
		}
    }
    public void actionDown(){
    	upDownValue-=yChange;
		if(upDownValue<0){
			upDownValue+=360;
		}
    }
    public void actionRight(){
    	rightLeftValue+=xChange;
		if(rightLeftValue>360){
			rightLeftValue-=360;
		}
    }
    public void actionLeft(){
    	rightLeftValue-=xChange;
		if(rightLeftValue<0){
			rightLeftValue+=360;
		}
    }
    public void actionCenter(){
    	rightLeftValue=0;
    	upDownValue=0;
    }






	@Override
	public void actionDown(int value) {
		actionDown();
	}






	@Override
	public void actionLeft(int value) {
		actionLeft();
	}






	@Override
	public void actionRight(int value) {
		actionRight();
	}






	@Override
	public void actionUp(int value) {
		actionUp();
	}






	@Override
	public boolean onTouchDown(float x, float y) {
		// TODO Auto-generated method stub
		return false;
	}






	@Override
	public boolean onTouchMove(float x, float y) {
		// TODO Auto-generated method stub
		return false;
	}






	@Override
	public boolean onTouchUp(float x, float y) {
		// TODO Auto-generated method stub
		return false;
	}





}




